package com.example.diagnose.Dto;


import cn.hutool.json.JSONUtil;
import com.example.diagnose.Config.ErnieBotTurboStreamParam;
import com.example.diagnose.Domain.BaiduChatMessage;
import com.example.diagnose.Domain.DiagnoseRecord;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;


import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
public class Record {
    private int diagnose_id;
    private String user_account;
    private LocalDateTime time;
//    private String record_link;
    private String record_title;
    private List<BaiduChatMessage> messages;

    public Record(DiagnoseRecord dr){
        this.setDiagnose_id(dr.getDiagnose_id());
        this.setUser_account(dr.getUser_account());
        this.setTime(dr.getTime());
//        this.setRecord_link(dr.getRecord_link());
        this.setRecord_title(dr.getRecord_title());

        String records = dr.getRecord_link();
        ErnieBotTurboStreamParam param = JSONUtil.toBean(records, ErnieBotTurboStreamParam.class);
        List<BaiduChatMessage> messages = param.getMessages() == null ? new ArrayList<>() : param.getMessages();
        this.setMessages(messages);
    }
}
